package org.gw.building.repositories;

import org.gw.building.model.Tyxxcjb;
import org.gw.building.model.base.Tyxxcjzb;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

/**
 * Created by qwx89 on 2017/8/6.
 */
public interface TyxxcjzbRepository extends CrudRepository<Tyxxcjzb,String> {
    @Query("from Tyxxcjzb t where t.yx.id = ?1 order by t.sbrq desc")
    Page<Tyxxcjzb> queryYxCjzb(String departmentId, Pageable pageable);

    @Query("select count(1) from Tyxxcjzb t where t.yx.id = ?1 and t.shzt.dm != 99")
    int getAuditNum(String departmentId);

    @Query("from Tyxxcjzb t where (?1 is null or t.yx.id = ?1) and (?2 is null or t.shzt.dm = ?2) order by t.yx.id asc,t.zbmc.id asc")
    Page<Tyxxcjzb> queryCjzb(String departmentId, String shzt, Pageable pageable);
}
